package org.kabeja.parser.table;

import org.kabeja.dxf.DXFConstants;
import org.kabeja.dxf.DXFDimensionStyle;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 12:28
 */
public class DXFDimensionStyleTableHandler extends AbstractTableHandler {
    public static final int GROUPCODE_NAME = 2;
    public static final int FLAGS = 70;
    private DXFDimensionStyle style;

    public DXFDimensionStyleTableHandler() {
    }

    @Override
    public void endParsing() {
        this.doc.addDXFDimensionStyle(this.style);
    }

    @Override
    public String getTableKey() {
        return DXFConstants.TABLE_KEY_DIMSTYLE;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case GROUPCODE_NAME:
                this.style.setName(var2.getValue());
                break;
            case FLAGS:
                this.style.setFlags(var2.getIntegerValue());
                break;
            default:
                this.style.setProperty("" + var1, var2.getValue());
        }

    }

    @Override
    public void startParsing() {
        this.style = new DXFDimensionStyle();
    }
}
